package com.yl.androidutilscenter.base.fragment

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import com.yl.androidutilscenter.base.BaseViewModel

/**
 * @author
 * @description:
 * @date :2024/3/13
 * @version 1.0.0
 */
abstract class BaseVmVbFragment<VM : BaseViewModel, VB : ViewDataBinding> : BaseVmFragment<VM>() {

    //该类绑定的 ViewBinding
    var mDataBinding: VB? = null

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        mDataBinding = DataBindingUtil.inflate(inflater, layoutId(), container, false)
        return if (mDataBinding == null) {
            inflater.inflate(layoutId(), container, false)
        } else {
            mDataBinding!!.root
        }
    }

    override fun onDestroyView() {
        super.onDestroyView()
        mDataBinding = null
    }

}